from flask import Blueprint, g
import logging
from common import ApiResponse, Result
from .service import UserService
from .entity import VipLogListModel, ApiLogListModel
from flask_pydantic import validate

LOGGER = logging.getLogger(__name__)
user_blueprint = Blueprint("user", __name__)

@user_blueprint.route("/info", methods=["POST"])
def info():
    try:
        res: Result = UserService().get_user_info(g.userid)

        if res.isSucc():
            # 这个roles 的结构，必须有，前端有代码依赖
            return ApiResponse().set_data({"roles": [], "user": res.data}).json()

        return ApiResponse().error(res.message).json()
    except Exception as e:
        LOGGER.exception(e)
        return ApiResponse().error(str(e)).json()


